stages:
  - build

image: docker:20

services:
  - docker:dind

.dockerize:
  stage: build
  tags: [docker]
  variables:
    IMAGE_TAG: latest
  before_script:
    - mkdir $HOME/.docker
    - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
  script:
    - docker build . -t zoidenberg/gate-up:$IMAGE_TAG
    - docker push zoidenberg/gate-up:$IMAGE_TAG

build_dev:
  extends: .dockerize
  only:
    - master

build_release:
  extends: .dockerize
  variables:
    IMAGE_TAG: $CI_COMMIT_TAG
  only:
    - tags
